package com.wis.mapper;

import com.wis.entity.BannerEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BannerMapper {
    @Insert("insert into banner (name,img,type) values (#{name},#{img},#{type})")
    int addBanner(BannerEntity banner);

    /**
     * 修改 banner
     *
     * @param banner
     * @return
     */
    @Update("update banner set name = #{name},type = #{type} where id = #{id}")
    int updateBanner(BannerEntity banner);

    /**
     * 修改 banner 的图片
     *
     * @param banner
     * @return
     */
    @Update("update banner set img = #{img} where id = #{id}")
    int updateBannerImg(BannerEntity banner);

    /**
     * 删除 banner
     *
     * @param id
     * @return
     */
    @Delete("delete from banner where id = #{id}")
    int delBanner(int id);

    /**
     * 查询所有
     *
     * @return
     */
    @Select("select * from banner")
    List<BannerEntity> showAll();

    /**
     * 根据轮播图名称查询轮播图,模糊查询
     * **/
    @Select("select * from banner where name like '%${name}%'")
    List<BannerEntity> showByName(@Param("name") String name);
}
